package com.rcadmin.busi.admin.action;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

import com.rcadmin.busi.admin.service.SysUserService;
import com.rcadmin.core.app.action.ActionException;
import com.rcadmin.core.app.session.SessionControl;
import com.rcadmin.core.web.BaseAction;

/**
 * 系统登陆
 * 
 */
@Controller
public class LoginController extends BaseAction {
	private static final String LOGIN_PAGE = "/admin/login";
	@Resource
	private SysUserService sysUserService;

	/**
	 * 跳转到用户登陆页
	 */
	@GetMapping("/toLogin.op")
	public ModelAndView toLogin() {
		return render(LOGIN_PAGE);
	}

	/**
	 * 用户退出
	 * 
	 * @throws ActionException
	 */
	@GetMapping("/logOut.op")
	public ModelAndView userLogOut() {
		try {
			SessionControl.removeUserInfo(request);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
		}
		return render(LOGIN_PAGE);
	}
}
